from django.shortcuts import render

# Create your views here.
from django.http import HttpResponse
from .models import Question
from django.template import loader
from django.shortcuts import render


def index(request):
    # return HttpResponse("Hello, world")
    latest_question_list = Question.objects.order_by('-pub_date')[:5]
    # output = ',' .join([q.question_text for q in latest_question_list])
    # return HttpResponse(output)
    context = {
        'latest_question_list': latest_question_list,
    }
    # return HttpResponse(template.render(context, request))
    return render(request, 'blog/index.html', context)

def detail(request, question_id):
    return HttpResponse("detail:You're looking at question %s." % question_id)

def results(request, question_id):
    response = "results:You're looking at question %s." % question_id
    return HttpResponse(response)

def vote(request, question_id):
    return HttpResponse("vote:  You're looking at question %s." % question_id)